<?php
/**
 * Copyright (C) 2013  Artur Tolstenco
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

class Agenziaterritorio_Mapper_Fabbricato extends Agenziaterritorio_Mapper_Abstract {
	public function __construct() {
		$this->table_name = 'Agenziaterritorio_Model_DbTable_Fabbricato';
	}
	
	public function delTitolare($cf) {
		$select = $this->getDbTable()->select();
		$select->where('cf_app = ?', $cf);
		$rows = $this->getDbTable()->fetchAll($select);
	
	
		if ($rows == null || count($rows) == 0)
			throw new Agenziaterritorio_Model_DataNotFoundException();
	
	
		$fabbricati = new Agenziaterritorio_Model_Fabbricati();
		
		foreach ($rows as $r)
			$fabbricati->add(new Agenziaterritorio_Model_Fabbricato($r->id, 
																	$r->rendita, 
																	$r->possesso_perc, 
																	$r->possesso_giorni, 
																	$r->codice_comune));
		
		return $fabbricati;
	}
}